package com.chzc.mq;

import com.chzc.server.DevilProducer;
import com.chzc.util.properties.DevilMqProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author cv大魔王
 * @version 1.0
 * @date 2021/6/23 8:14
 */
@Component
public class DevilMQUtil {


    @Autowired
    private DevilMqProperties devilMqProperties;

    /**
     * 发送消息
     * @return
     */
    @Bean
    public DevilProducer getProducer(){
        System.out.println(devilMqProperties.getHost());
        System.out.println(devilMqProperties.getPort());
        // 创建普通消息生产者连接
        DevilProducer devilProducer = new DevilProducer(devilMqProperties.getHost(), devilMqProperties.getPort());
        // 启动连接,需要先启动连接在发送消息
        devilProducer.start();
        return devilProducer;
    }
}
